package cn.heyige.backend.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = "用户信息响应V2")
public class UserProfileResponse {
    
    @Schema(description = "用户ID", example = "user_1704096000123")
    private String userId;
    
    @Schema(description = "脱敏手机号", example = "138****8000")
    private String phone;
    
    @Schema(description = "昵称", example = "易学爱好者")
    private String nickname;
    
    @Schema(description = "头像URL")
    private String avatar;
    
    @Schema(description = "真实姓名（脱敏）", example = "张**")
    private String realName;
    
    @Schema(description = "性别", allowableValues = {"MALE", "FEMALE", "OTHER"})
    private String gender;
    
    @Schema(description = "生日")
    private LocalDate birthday;
    
    @Schema(description = "位置信息")
    private LocationInfo location;
    
    @Schema(description = "等级", example = "进阶者")
    private String level;
    
    @Schema(description = "经验值", example = "1250")
    private Integer experience;
    
    @Schema(description = "下一等级所需经验", example = "2000")
    private Integer nextLevelExperience;
    
    @Schema(description = "会员类型", example = "VIP")
    private String membershipType;
    
    @Schema(description = "会员到期时间")
    private LocalDateTime membershipExpiry;
    
    @Schema(description = "统计信息")
    private StatisticsInfo statistics;
    
    @Schema(description = "偏好设置")
    private PreferencesInfo preferences;
    
    @Schema(description = "创建时间")
    private LocalDateTime createdAt;
    
    @Schema(description = "最后登录时间")
    private LocalDateTime lastLoginAt;
    
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "位置信息")
    public static class LocationInfo {
        @Schema(description = "省份", example = "广东省")
        private String province;
        
        @Schema(description = "城市", example = "深圳市")
        private String city;
    }
    
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "统计信息")
    public static class StatisticsInfo {
        @Schema(description = "总占卜次数", example = "28")
        private Integer totalDivinations;
        
        @Schema(description = "收藏数量", example = "15")
        private Integer favoriteCount;
        
        @Schema(description = "AI解读次数", example = "25")
        private Integer totalInterpretations;
        
        @Schema(description = "准确率评分", example = "4.2")
        private Double accuracyRating;
        
        @Schema(description = "注册天数", example = "90")
        private Integer registrationDays;
    }
    
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "偏好设置")
    public static class PreferencesInfo {
        @Schema(description = "默认算法", example = "TRADITIONAL")
        private String defaultAlgorithm;
        
        @Schema(description = "AI模型", example = "WENXIN")
        private String aiModel;
        
        @Schema(description = "解读等级", example = "PROFESSIONAL")
        private String interpretationLevel;
        
        @Schema(description = "是否开启通知", example = "true")
        private Boolean notificationEnabled;
        
        @Schema(description = "隐私等级", example = "NORMAL")
        private String privacyLevel;
    }
}